// 封装获取频道列表的逻辑
import {useEffect, useState} from "react";
import {getChannels} from "@/apis/article";

function useChannel() {
//     1. 获取频道列表的所有逻辑
    const [channels, setChannels] = useState([]);
    useEffect(() => {
        async function getChannelList() {
            const res = await getChannels();
            setChannels(res.data.channels)
        }

        getChannelList()
    }, [])
//     2. 把数据导出
    return {channels};
}

export {useChannel}